﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;

namespace Robot.CrawlerService.Crawler
{
    public class HttpCrawler
    {
        public string Grab(string url)
        {
            try
            {
                WebRequest request = HttpWebRequest.Create(url);
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;
                Stream s = response.GetResponseStream();
                StreamReader sr = new StreamReader(s);
                string html = sr.ReadToEnd();
                sr.Close();
                s.Close();
                return html.Trim().Replace("\r", "").Replace("\n", ""); ;
            }
            catch (Exception e)
            {
                return string.Empty;
            }
        }
    }
}
